//
//  ClassModel.m
//  SchoolTimetable
//
//  Created by 梦里都是梦 on 16/1/12.
//  Copyright © 2016年 Yuanlinqian. All rights reserved.
//

#import "ClassModel.h"

@implementation ClassModel
-(void)encodeWithCoder:(NSCoder *)aCoder
 {
     [aCoder encodeInteger:self.weekTime forKey:@"weekTime"];
     [aCoder encodeInteger:self.startTime forKey:@"startTime"];
     [aCoder encodeInteger:self.endTime forKey:@"endTime"];
     [aCoder encodeObject:self.viewColor forKey:@"color"];
     [aCoder encodeObject:self.className forKey:@"className"];
     [aCoder encodeObject:self.classTea forKey:@"classTea"];
     [aCoder encodeObject:self.classRoom forKey:@"classRoom"];
 }

 // 当从文件中读取一个对象的时候就会调用该方法
 // 在该方法中说明如何读取保存在文件中的对象
 // 也就是说在该方法中说清楚怎么读取文件中的对象
-(id)initWithCoder:(NSCoder *)aDecoder
 {
     //注意：在构造方法中需要先初始化父类的方法
     if (self=[super init]) {
         self.weekTime=[aDecoder decodeIntegerForKey:@"weekTime"];
         self.startTime=[aDecoder decodeIntegerForKey:@"startTime"];
         self.endTime=[aDecoder decodeIntegerForKey:@"endTime"];
         self.viewColor=[aDecoder decodeObjectForKey:@"color"];
         self.className=[aDecoder decodeObjectForKey:@"className"];
         self.classTea=[aDecoder decodeObjectForKey:@"classTea"];
         self.classRoom=[aDecoder decodeObjectForKey:@"classRoom"];
     }
     return self;
}

@end
